<?php

use App\Models\ChatGroup\ChatGroupUserModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AddColumnTagToChatGroupUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('chat_group_users', function (Blueprint $table) {
            $table->unsignedTinyInteger('tag')->default(0)->comment('用户标识 1-小助手 2-在线客服 3-收银顾问')->after('role');
        });

        ChatGroupUserModel::query()->where('userId', 1)->update(['tag' => ChatGroupUserModel::TAG_ASSISTANT]);
        ChatGroupUserModel::query()->whereIn('alias', [
            '比鲁斯', '美乐蒂' , '珊迪' , '辰月', '星魂'
        ])->update(['tag' => ChatGroupUserModel::TAG_CUSTOMER_SERVICE]);

        ChatGroupUserModel::query()->whereIn('alias', [
            '颜路', '画玖'
        ])->update(['tag' => ChatGroupUserModel::TAG_CASHIER_CONSULTANT]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('chat_group_users', function (Blueprint $table) {
            $table->dropColumn('tag');
        });
    }
}
